import React from 'react'
import Taro from '@tarojs/taro'
import { AtTabs} from 'taro-ui'
import {DepartmentList} from './DepartmentList'

class TabListDepartment extends React.Component{
    constructor () {
      super(...arguments)
      this.state = {
        current: 0,
      }
    }
    handleClick (value) {
      this.setState({
        current: value
      })
    }

    render(){
      const department_tool = this.props.data
      var length=department_tool.length
      var items=[]
      for(var i=0;i<length;i++){
        items.push({title:department_tool[i].bigKind})
      }
      const listHeight = Taro.getSystemInfoSync().windowHeight - 100
      return(        
        <AtTabs current={this.state.current}
              scroll
              tabDirection='vertical'
              height={listHeight+'px'}
              tabList={items}
              onClick={this.handleClick.bind(this)}> 
        {department_tool.map((item,index)=>{
            return <DepartmentList index={index} department={item.department}>
            </DepartmentList>
          })}
        </AtTabs>
      )
    }
}

export {TabListDepartment}